﻿using Microsoft.CSharp.Activities;
using System;
using System.Activities;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WFExtended.Twitter.Activities.Designers;

namespace WFExtended.Twitter.Activities
{
    /// <summary>
    /// Returns the most recent tweets authored by the authenticating user that have been retweeted by others. 
    /// </summary>
    [ToolboxBitmapAttribute(typeof(EntryPoint), "Resources.TimelineToolbox.bmp")]
    [Designer(typeof(TimelineDesigner))]
    [Description("Returns the most recent tweets authored by the authenticating user that have been retweeted by others.")]
    public class GetRetweetsOfMe : TwitterOperationInvoker<List<Status>>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="GetRetweetsOfMe"/> class.
        /// </summary>
        public GetRetweetsOfMe()
            : base("GetRetweetsOfMe")
        {
            Count = new InArgument<int>(new CSharpValue<int>("50"));
            IncludeEntities = new InArgument<bool>(new CSharpValue<bool>("true"));
            TrimUser = new InArgument<bool>(new CSharpValue<bool>("false"));
            IncludeUserEntities = new InArgument<bool>(new CSharpValue<bool>("true"));
        }

        /// <summary>
        /// The number of direct messages to return per page, up to a maximum of 100. Defaults to 20
        /// <remarks>Example Values: 100</remarks>
        /// </summary>
        /// <value>
        /// Number of direct messages per page
        /// </value>
        [Browsable(true)]
        [Category("Navigation")]
        [Description("Number of tweets per page")]
        [RequiredArgument]
        public InArgument<int> Count { get; set; }

        // <summary>
        /// Returns results with an ID greater than (that is, more recent than) the specified ID. 
        /// </summary>
        /// <value>
        /// Results with an ID greater than
        /// </value>
        [Browsable(true)]
        [Category("Navigation")]
        [Description("Results with an ID greater than")]
        public InArgument<string> SinceID { get; set; }

        /// <summary>
        /// Returns results with an ID less than (that is, older than) or equal to the specified ID.
        /// </summary>
        /// <value>
        /// Results with an ID less than
        /// </value>
        [Browsable(true)]
        [Category("Navigation")]
        [Description("Results with an ID less than")]
        public InArgument<string> MaxID { get; set; }

        /// <summary>
        /// When set to either true, each tweet returned in a timeline will include a user object including only the status authors numerical ID.
        /// </summary>
        /// <value>
        /// Trim User Value
        /// </value>
        [Browsable(true)]
        [Category("Parameters")]
        [Description("When set to either true, each tweet returned in a timeline will include a user object including only the status authors numerical ID.")]
        [RequiredArgument]
        public InArgument<bool> TrimUser { get; set; }

        /// <summary>
        /// The user entities node will be disincluded when set to false.
        /// </summary>
        /// <value>
        /// The user entities node will be disincluded when set to false.
        /// </value>
        [Browsable(true)]
        [Category("Parameters")]
        [Description("The user entities node will be disincluded when set to false.")]
        [RequiredArgument]
        public InArgument<bool> IncludeEntities { get; set; }

        /// <summary>
        /// Gets or sets the include user entities.
        /// </summary>
        /// <value>
        /// The include user entities.
        /// </value>
        [Browsable(true)]
        [Category("Parameters")]
        [Description("The entities node will be disincluded when set to false")]
        [RequiredArgument]
        public InArgument<bool> IncludeUserEntities { get; set; }


        /// <summary>
        /// Caches the metadata.
        /// </summary>
        /// <param name="metadata">The metadata.</param>
        protected override void CacheMetadata(NativeActivityMetadata metadata)
        {
            RuntimeArgument countArgument = new RuntimeArgument("Count", typeof(int), ArgumentDirection.In, true);
            metadata.Bind(Count, countArgument);
            metadata.AddArgument(countArgument);

            RuntimeArgument sinceIDArgument = new RuntimeArgument("SinceID", typeof(string), ArgumentDirection.In, false);
            metadata.Bind(SinceID, sinceIDArgument);
            metadata.AddArgument(sinceIDArgument);

            RuntimeArgument maxIDArgument = new RuntimeArgument("MaxID", typeof(string), ArgumentDirection.In, false);
            metadata.Bind(MaxID, maxIDArgument);
            metadata.AddArgument(maxIDArgument);

            RuntimeArgument includeEntitiesArgument = new RuntimeArgument("IncludeEntities", typeof(bool), ArgumentDirection.In, true);
            metadata.Bind(IncludeEntities, includeEntitiesArgument);
            metadata.AddArgument(includeEntitiesArgument);

            RuntimeArgument trimUserArgument = new RuntimeArgument("TrimUser", typeof(bool), ArgumentDirection.In, true);
            metadata.Bind(TrimUser, trimUserArgument);
            metadata.AddArgument(trimUserArgument);

            RuntimeArgument includeUserEntitiesArgument = new RuntimeArgument("IncludeUserEntities", typeof(bool), ArgumentDirection.In, true);
            metadata.Bind(IncludeUserEntities, includeUserEntitiesArgument);
            metadata.AddArgument(includeUserEntitiesArgument);

            base.CacheMetadata(metadata);
        }

        /// <summary>
        /// Executes the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void Execute(NativeActivityContext context)
        {
            Parameters.Clear();

            Parameters.Add("count", Count);
            Parameters.Add("sinceID", SinceID);
            Parameters.Add("maxID", MaxID);
            Parameters.Add("trimUser", TrimUser);
            Parameters.Add("includeEntities", IncludeEntities);
            Parameters.Add("includeUserEntities", IncludeUserEntities);


            base.Execute(context);
        }


    }
}
